package com.dlc.apk.api

import android.text.TextUtils
import com.dlc.apk.utils.DeviceUtil

/**
 * @author We
 */
object ApiConstants {
    const val BASE_URL = "http://gzqfzdzy.app.xiaozhuschool.com"
    const val CODE_SUCCESS = 1

    /*上传日志文件*/
    const val uploadLogUrl = "http://anzhuologs.app.xiaozhuschool.com/App/Upload/index"
    val uploadLogMQTTTopic = "${DeviceUtil.packageName}/${DeviceUtil.androidId}/uploadLog"

    //MQTT后台发布的topic
    private const val topicPrefix = "gzqfzdzy_apk"
    val serverPublishTopic = "${topicPrefix}/${DeviceUtil.androidId}"

    //MQTT后台发布的topic
    val serverPublishTopic2 = "${topicPrefix}/common"

    //MQTT后台订阅的topic
    private const val apkTopicPrefix = "gzqfzdzy_php"
    val serverSubscribeTopic = "${apkTopicPrefix}/${DeviceUtil.androidId}"

    //MQTT broker
    const val brokerUri = "tcp://120.77.72.190:1883"
    const val brokerUserName = "dlc"
    const val brokerPassword = "123456"

    fun getFullUrl(path: String = ""): String {
        if (TextUtils.isEmpty(path)) {
            return BASE_URL
        }
        if (path.startsWith("http://") || path.startsWith("https://")) {
            return path
        }
        return BASE_URL + path
    }

    const val EVENT_MQTT_RESTART = "EVENT_MQTT_RESTART"
    const val EVENT_MQTT_UPDATE_ADVERT = "EVENT_MQTT_UPDATE_ADVERT"
    const val EVENT_MQTT_UPDATE_VERSION = "EVENT_MQTT_UPDATE_VERSION"
    const val EVENT_MQTT_CONFIG_TEMPERATURE = "EVENT_MQTT_CONFIG_TEMPERATURE"

    const val EVENT_MQTT_START_SHIPMENT = "EVENT_MQTT_START_SHIPMENT"
    const val EVENT_TASK_RUNNING_DEVICE_BUSY = "EVENT_TASK_RUNNING_DEVICE_BUSY"
    const val EVENT_MQTT_TESTING_SHIPMENT = "EVENT_MQTT_TESTING_SHIPMENT"
    const val EVENT_MQTT_TESTING_SHIPMENT_PROGRESS = "EVENT_MQTT_TESTING_SHIPMENT_PROGRESS"

    const val EVENT_HARDWARE_WORK_DATA_UPDATED = "EVENT_HARDWARE_WORK_DATA_UPDATED"
    const val EVENT_DEVICE_INFO_UPDATED = "EVENT_DEVICE_INFO_UPDATED"
}